#ifndef __FSM_H__
#define __FSM_H__

#define BUFSIZE 1024

enum {STATE_R, STATE_W, STATE_E, STATE_T};

typedef struct {
	int rfd, wfd;
	int state;
	char buf[BUFSIZE];
	int read_cnt;
	int pos;
	char *errmsg;
} fsm_t;

int fsm_init(fsm_t **my_fsm, int rfd, int wfd);

int fsm_drive(fsm_t *my_fsm);

int fsm_destroy(fsm_t **my_fsm);

#endif

